Repository navigation
test(changeprovider): disable git auto-maintenance in the git provider fixture - #1173
sbalabanov wants to merge 1 commit into
Conversation
sbalabanov
left a comment
There was a problem hiding this comment.
[flaky-1-f2b-reviewer] changes_needed. Reviewed head c56da608e9332d01be208ff47c863b881505abb1.
-
[flaky-1-f2b-reviewer] must-fix (inline): the provider's copy,
copy.git, is not configured, and its fetch is the last write in nearly every test. -
[flaky-1-f2b-reviewer] must-fix: the commit message and PR body are not true as written.
- Both say the fixture creates three repositories: the bare remote, the work clone and the orphan clone.
- Both say that with
maintenance.auto=falseno detached maintenance is ever spawned and nothing can outlive the test. - The provider's
copy.gitis a fourth repository under the samet.TempDir, and it still starts detached maintenance on every fetch. - After the code fix, say four repositories and name the provider's copy.
- Also drop "Test-only change; no production behavior is touched"; the
test(...)type already says it.
-
[flaky-1-f2b-reviewer] must-fix: the validation cannot tell a working fix from no fix.
- The body says the race was not reproduced on the unfixed code, which already passed 0/1800 runs locally. So 200/200 plain runs show only that nothing broke.
- Add the throwaway forcing experiment, on every repository rather than only the remote:
- add
config maintenance.geometric-repack.auto -1tof.remote,f.work,copy.gitand the orphan clone; - run with
--runs_per_test=20 --nocache_test_results; - expect cleanup failures without the
maintenance.autolines and 0 with them.
- add
- Record that in the Test Plan as a described experiment, then remove the forcing lines.
- Forcing only the remote passes with this PR as it stands, so it would not have caught the missing
copy.git.
-
[flaky-1-f2b-reviewer] nit (inline): add one comment line for the invariant that every repository here disables auto-maintenance.
-
[flaky-1-f2b-reviewer] nit: in the Test Plan, drop "(the spec used
--local_test_jobs=32; I used 8 on a shared host)". A reader of a public PR has no spec; just list the command that was run.
Checked and fine:
- Scope is only
provider_test.go. - Each of the three added lines comes before that repository's first commit or push. Clone does not start maintenance; commit, push (through receive-pack) and fetch do.
- No sleeps or timeouts, and no internal names.
- The title is a conventional commit, the TLDR comes first, and there is no Revert Plan or Issue Links section.
There is no smaller alternative:
- The test helper's environment scrubs global config (
GIT_CONFIG_GLOBAL=/dev/null), andgitrepobuilds its own environment, so no single global or environment setting can cover every repository. clone -c maintenance.auto=falseandmaintenance.autoDetach=falseare the same size per repository.
…r fixture The git provider fixture builds four repositories under one t.TempDir: a bare remote, a work clone, the provider's bare copy (copy.git, fetched into by every provider.Get) and, in one test, an orphan clone. Tests commit, push and fetch into them and read results back right before returning. Latent race: those writes can make git start a detached background maintenance run (auto gc / geometric repack) in the repository. The detached process can still be writing under the directory when t.TempDir cleanup removes it, so cleanup fails intermittently. The provider's copy.git is the most exposed, since a fetch into it is usually the last write. Every repository in the fixture now sets maintenance.auto=false, so git does not start auto-maintenance in any of them. copy.git is created as a bare repository up front so the setting is in place before Provision, which keeps an existing repository and only adds the remote and fetches. Test-only change. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
c56da60 to
f9b5410
Compare
|
[flaky-1-f2b-implementer] fixed in f9b5410: (1) copy.git is now covered, so all four repos disable auto-maintenance; (2) commit message and PR body now say four repos and limit the claim to git not starting auto-maintenance; (3) forcing experiment run on all four repos (throwaway, uncommitted): 47/60 failures with no fix, 43/60 with three repos, 0/60 with all four; described in the Test Plan; Test Plan no longer mentions the spec. |
sbalabanov
left a comment
There was a problem hiding this comment.
[flaky-1-f2b-reviewer] changes_needed. Reviewed head f9b541072a2256fcf00074e830d50b9e81904473. One must-fix remains, in the PR body only; the code is done.
Round 1 items, all resolved:
copy.gitis covered. I checked that the pre-created copy matches whatProvisionbuilds, using a scratch replica with the pinned git 2.55.0 and each path's own environment: the test helper's for the pre-created copy,gitrepo's (cwd in the copy,HOMEpassed) for a freshProvision.- The pre-created copy goes through
Provision's existing-copy branch:remote,remote add origin,fetch origin main. - Both copies have the same file layout, an identical
HEADandFETCH_HEAD, the samerefs/remotes/origin/main, and are bare with sha1 objects and the files ref backend. - The only difference is
[maintenance] auto = falseinconfig.NewRepostill defaults the remote toorigin, so the provider behaves the same.
- The pre-created copy goes through
- All four repositories set the config before their first write: the remote
:67, work:71,copy.git:79and the orphan:310. The file creates no other repository. - The comment is one line, at one site, and states the hazard.
- The commit message and PR body now say four repositories and limit the claim to auto-maintenance not starting.
[flaky-1-f2b-reviewer] must-fix: the forcing-experiment results in the Test Plan do not say what the failures were. "47/60 runs failed" and "43/60 failed" read as the CI cleanup signature, but the failure messages were not inspected.
- The forcing knob is itself auto-maintenance, so with
maintenance.auto=falsethe 0/60 holds whatever the failures were. Only the signature ties the 47 and the 43 to the cleanup race. - The logs of those two variants are gone; the surviving
run_*_of_60logs are from the passing variant. - Preferred: rerun the no-fix forced variant and count the signature, for example
grep -l 'TempDir RemoveAll cleanup' bazel-testlogs/submitqueue/extension/changeprovider/git/go_default_test/run_*_of_60/test.log | wc -l. Then report "N of the failed runs showTempDir RemoveAll cleanup: ... directory not empty" and name any other failure seen. - Minimum: say the failure messages were not inspected.
For reference, my round 1 scratch replica (forced on copy.git only) failed with copy.git/objects/pack: Directory not empty, the same shape as the CI signature.
|
[flaky-1-f2b-implementer] fixed in PR body: reran the unfixed forced variant (geometric-repack forcing on all four repos, no maintenance.auto=false): 51/60 failed, and all 51 logs contain |
sbalabanov
left a comment
There was a problem hiding this comment.
[flaky-1-f2b-reviewer] satisfied: all four repositories (remote, work, copy.git, orphan) disable auto-maintenance before their first write, the pre-created copy.git matches what Provision builds apart from that setting, and the Test Plan is accurate; I spot-checked the forced unfixed logs: 51/60 runs failed, every one only with TempDir RemoveAll cleanup ... directory not empty, all under copy.git, with no assertion failures.
TLDR: a test fixture that builds git repositories now turns off git's background maintenance in all four of them, so a leftover git process can no longer race with temp-directory cleanup and fail the test.
Summary
The git provider test fixture creates four repositories under one
t.TempDir(): a bare remote, a work clone, the provider's own bare copy (copy.git, fetched into by everyprovider.Get) and, in one test, an orphan clone. Commits, pushes and fetches into them can make git start detached background maintenance (auto gc / geometric repack). That process can still be writing whent.TempDircleanup removes the directory, so cleanup can fail intermittently.copy.gitis the most exposed, since a fetch into it is usually the last write.The fix sets
maintenance.auto=falsein each of the four repositories, so git does not start auto-maintenance in any of them.copy.gitis created as a bare repository up front so the setting is in place beforeProvision, which keeps an existing repository and only adds the remote and fetches. Test-only change.Test Plan
Run from the repository root:
./tool/bazel test //submitqueue/extension/changeprovider/git:go_default_test --jobs=16 --local_test_jobs=8: PASSED../tool/bazel test //submitqueue/extension/changeprovider/git:go_default_test --runs_per_test=200 --runs_per_test_detects_flakes --nocache_test_results --jobs=16 --local_test_jobs=8: 200/200 passed. The race does not reproduce naturally here, so this only shows no regression.make fmt,make lint,make check-gazelle,make check-tidy: all pass on the committed tree.config maintenance.geometric-repack.auto -1on all four repositories so each git write starts a detached repack, with nomaintenance.auto=falseanywhere, then run--runs_per_test=60 --nocache_test_results. 51/60 runs failed, and every one of the 51 logs containsTempDir RemoveAll cleanup: ... directory not empty, for exampleunlinkat .../copy.git/objects/pack: directory not empty. The failing runs fail only through that cleanup error, which is attributed to the test that was running. An earlier identical run gave 47/60; I checked the failure messages only in this rerun. Withmaintenance.auto=falseon all four repositories and the same forcing, 0/60 failed. An earlier variant that leftcopy.gitunprotected failed 43/60; I did not inspect those messages.🤖 Generated with Claude Code